'''
上次图片接口： http://192.168.150.84:8088/carRental/file/uploadFile.action
添加车辆接口：http://192.168.150.84:8088/carRental/car/addCar.action

'''

import requests

url = "http://192.168.150.84:8088/carRental/file/uploadFile.action"

path = "C:\\Users\Administrator\Desktop\\1234.png"  # 要上传的文件
with open(path, mode='rb') as f:
    # mf是uploadFile.action接口定义的参数名
    # path要打开上传的文件
    # f fileobj 打开文件后，文件对象
    #fs = {"mf": (path, f)}  # 二元组
    fs = {"mf": (path, f,"image/png")}  #三元组Content-Type表示上传文件的类型
    r = requests.post(url, files=fs)
    print(r.text)
    print(r.request.headers)    #'Content-Type': 'multipart/form-data'
    print(r.json()['data']['src']) #文件路径

#